#!/bin/bash

cwd=$(pwd)

# 基本工具
sudo apt install emacs vim xclip xsel zsh git manpages-posix manpages-posix-dev manpages-dev silversearcher-ag curl

chsh -s $(which zsh)

## bbr for linux > 4.9.x
# sysctl net.ipv4.tcp_congestion_control
sudo tee -a /etc/sysctl.d/90-bbr.conf > /dev/null << 'EOF'
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
EOF

# 安装oh-my-zsh
# https://github.com/robbyrussell/oh-my-zsh/
sh -c "$(curl -k -L https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# 设置/etc/profile
sudo tee -a /etc/profile > /dev/null << 'EOF'

# set environment variables
export EDITOR='env LC_CTYPE=zh_CN.UTF-8 emacs'
export JAVA_HOME=/opt/jdk
export GOROOT=/opt/go
export NODE=/opt/node
export GOPATH=/home/tengyft/GoWork
export PATH=$GOROOT/bin:$NODE/bin:$GOPATH/bin:$JAVA_HOME/bin:$PATH
export WINEARCH=win32

# mp3 tag gbk
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030
EOF

# 设置spacemacs
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

sudo tee -a /etc/sysctl.d/90-inotify.conf > /dev/null <<EOF
fs.inotify.max_user_watches = 524288
EOF

# powerline fonts
git clone https://github.com/powerline/fonts.git --depth=1 ~/fonts
~/fonts/install.sh
rm -rf ~/fonts

# copy some personal desktop entry
cp ${cwd}/desktop/*.desktop ~/.local/share/applications
